﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using static System.Net.Mime.MediaTypeNames;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows;

namespace TestWpfCaliburn.Converters;

public class LeftDockTextConverter : IValueConverter
{
    public object? Convert(object? value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is null) return null;

        string txt = value!.ToString();

        if (txt.Length <= 0) return null;

        var roorigin = new Point(0.5, 0.5);
        var rotate = new RotateTransform() { Angle = 270 };
        rotate.Freeze();

        var ele = new StackPanel() { Background = Brushes.AliceBlue };
        foreach (char jc in txt.Reverse())
        {
            var tb = new TextBlock() { Text = jc.ToString(), RenderTransformOrigin = roorigin, LayoutTransform = rotate };
            ele.Children.Add(tb);
        }
        return ele;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}